Title: SQL W3S (By-BKK) / 123 SQL Server
Tags: Obsidian_to_Anki

Q: What does the ASCII() function return?
A: The ASCII() function returns the ASCII value for a specific character

Q: What does CHAR() do in SQL Server?
A: CHAR() returns the character based on the ASCII code

Q: Which function finds the position of a substring in a string?
A: CHARINDEX()

Q: True/False: CONCAT() can add multiple strings together
A: True

Q: What is the difference between CONCAT() and CONCAT_WS()?
A: CONCAT() joins strings directly, CONCAT_WS() joins with a separator

Q: How to count the bytes used to represent an expression?
A: Use DATALENGTH()

Q: What does the DIFFERENCE() function compare?
A: It compares two SOUNDEX values and returns an integer

Q: FORMAT() function
A: Formats a value with the specified format

Q: How do you extract a number of characters from the left of a string?
A: Use LEFT()

Q: Which function returns the length of a string in SQL Server?
A: LEN()

Q: How do you convert a string to lowercase in SQL Server?
A: Use LOWER()

Q: What is the use of LTRIM()?
A: LTRIM() removes leading spaces from a string

Q: Define NCHAR() function
A: NCHAR() returns the Unicode character for the given code

Q: How to find the position of a pattern in a string?
A: Use PATINDEX()

Q: QUOTENAME() function purpose
A: Adds delimiters to make a string a valid SQL delimited identifier

Q: How can you replace all occurrences of a substring with another string?
A: Use REPLACE()

Q: True/False: REPLICATE() repeats a string for a set number of times
A: True

Q: What does REVERSE() return?
A: REVERSE() returns a reversed string

Q: How do you extract characters from the right side of a string?
A: Use RIGHT()

Q: RTRIM() function usage
A: Removes trailing spaces from a string

Q: Which function evaluates the similarity of two strings?
A: SOUNDEX()

Q: What does SPACE() do in SQL Server?
A: SPACE() returns a string with a specified number of spaces

Q: How to convert a number to a string?
A: Use STR()

Q: STUFF() function
A: Deletes part of a string and inserts another part at a specific position

Q: Extract part of a string in SQL Server
A: Use SUBSTRING()

Q: TRANSLATE() function purpose
A: Substitutes specified characters in a string with others

Q: How to remove both leading and trailing spaces from a string?
A: Use TRIM()

Q: True/False: UNICODE() finds the Unicode value for the first character in an expression
A: True

Q: UPPER() function
A: Converts a string to uppercase

Q: Which SQL function returns absolute value?
A: ABS()

Q: ACOS() returns
A: Arc cosine of a number

Q: ASIN() returns
A: Arc sine of a number

Q: ATAN() vs ATN2()
A: ATAN() returns arc tangent of a number, ATN2() uses two numbers

Q: AVG() in SQL Server
A: Returns average value of an expression

Q: What does CEILING() function do?
A: Returns smallest integer greater than or equal to a number

Q: How to count rows in a select query?
A: Use COUNT()

Q: COS() function returns
A: Cosine of a number

Q: Which function gives the cotangent of a number?
A: COT()

Q: Convert radians to degrees
A: Use DEGREES()

Q: EXP() returns
A: e raised to the power of a specified number

Q: Find the largest integer less than or equal to a number
A: Use FLOOR()

Q: LOG() vs LOG10()
A: LOG() is natural logarithm or custom base, LOG10() is base 10

Q: MAX() vs MIN()
A: MAX() returns highest value, MIN() returns lowest value

Q: PI() function
A: Returns the value of PI

Q: How to calculate exponentiation in SQL Server?
A: Use POWER()

Q: Convert degrees to radians
A: Use RADIANS()

Q: RAND() function
A: Returns a random number

Q: Round a number in SQL Server
A: Use ROUND()

Q: SIGN() function usage
A: Returns the sign of a number

Q: Find sine, square root, square, tangent
A: Use SIN(), SQRT(), SQUARE(), TAN()

Q: How to get current date and time in SQL Server?
A: Use CURRENT_TIMESTAMP

Q: DATEADD() function
A: Adds a date/time interval to a date

Q: Difference between two dates
A: Use DATEDIFF()

Q: Construct a date from year, month, day
A: Use DATEFROMPARTS()

Q: Extract part of a date as string
A: Use DATENAME()

Q: Extract part of a date as integer
A: Use DATEPART()

Q: DAY() function usage
A: Returns day of the month for a date

Q: GETDATE() function
A: Current database system's date and time

Q: GETUTCDATE() function
A: Current database system's UTC date and time

Q: ISDATE() returns
A: 1 if input is a valid date, else 0

Q: How to get month part from a date?
A: Use MONTH()

Q: SYSDATETIME() function
A: Returns date and time of SQL Server

Q: How to get year part from a date?
A: Use YEAR()

Q: CAST() vs CONVERT()
A: Both convert value types, CAST() uses standard syntax, CONVERT() supports formatting

Q: What does COALESCE() return?
A: First non-null value in a list

Q: CURRENT_USER returns
A: Name of the current SQL Server user

Q: IIF() usage
A: Returns value based on a condition (TRUE or FALSE)

Q: When do you use ISNULL()?
A: To return a value if an expression is NULL, else return the expression

Q: ISNUMERIC() function
A: Checks if an expression is numeric

Q: NULLIF() function
A: Returns NULL if two expressions are equal

Q: SESSION_USER vs SYSTEM_USER
A: SESSION_USER returns SQL username, SYSTEM_USER returns login name

Q: USER_NAME()
A: Returns user name based on specified id

Q: First non-null value in a list
A: COALESCE()

Q: What function checks if a value is numeric?
A: ISNUMERIC()

Q: Remove leading spaces from a string
A: LTRIM()